﻿@using MC.RideEvent.Mvc.Helpers
@using MC.RideEvent.Mvc.Models.ViewModel
@model IEnumerable<WayViewModel>
@{
    var member = Session["CurrentMember"] as MemberViewModel;

    var listCurrentWays = Model.Where(w => w.Event.DateBegin >= DateTime.Now && w.Event.DateEnd <= DateTime.Now);
    var listComingWays = Model.Where(w => w.Event.DateBegin > DateTime.Now);
    var listPerformedWays = Model.Where(w => w.Event.DateBegin < DateTime.Now);
}
<p>
    @*@Html.ActionLink("Create New", "Create")*@
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.DriverId)
        </th>
        <th>
            @Html.DisplayName("Intitulé")
        </th>
        <th>
            @Html.DisplayName("Vehicule")
        </th>
        <th>
            @Html.DisplayName("Participation")
        </th>
        <th>
            @Html.DisplayName("Heure rendez-vous")
        </th>
        <th>
            @Html.DisplayName("Lieu rendez-vous")
        </th>
        <th>
            @Html.DisplayName("Ville rendez-vous")
        </th>
        <th>
            @Html.DisplayName("Nombre de place disponible")
        </th>
        <th>
            @Html.DisplayName("Date evenement")
        </th>
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.DriverId)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Event.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.VehiculeId)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contribution)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MeetingHour)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MeetingPlace)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.City)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.NumberPlaces)
            </td>
        
            <td>
                @Html.Display(item.Event.DateBegin.ToStringFr())
            </td>
            <td>
                @*@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })*@
            </td>
        </tr>
    }
</table>

<div class="list-waydriver">
    <h3>Trajets du jour (@listCurrentWays.Count())</h3>
    @foreach(var item in listCurrentWays)
    {
        <div class="item-way">
            <div class="field">
                <label>Evenement</label>
                <span>@item.Event.Title - @item.Event.DateBegin.ToStringFr() (@item.Event.City)</span>
            </div>
            <div class="field">
                <label>Vehicule</label>
                <span>@item.Vehicule.BrandAndModelToString</span>
            </div>
            <div class="field">
                <label>Rendez-vous</label>
                <span>@item.MeetingPlace - @item.MeetingHour</span>
            </div>
            <div class="field">
                <label>Participation</label>
                <span>@item.Contribution</span>
            </div>
            <div class="field">
                <label>Places disponibles</label>
                <span>@item.NumberPlaces</span>
            </div>
        </div>
    }
</div>

<div class="list-waydriver">
    <h3>Trajets avenirs (@listComingWays.Count())</h3>
    @foreach(var item in listComingWays)
    {
        <div class="item-way">
            <div class="field">
                <label>Evenement</label>
                <span>@item.Event.Title - @item.Event.DateBegin.ToStringFr() (@item.Event.City)</span>
            </div>
            <div class="field">
                <label>Vehicule</label>
                <span>@item.Vehicule.BrandAndModelToString</span>
            </div>
            <div class="field">
                <label>Rendez-vous</label>
                <span>@item.MeetingPlace - @item.MeetingHour</span>
            </div>
            <div class="field">
                <label>Participation</label>
                <span>@item.Contribution</span>
            </div>
            <div class="field">
                <label>Places disponibles</label>
                <span>@item.NumberPlaces</span>
            </div>
        </div>
    }
</div>

<div class="list-waydriver">
    <h3>Trajets effectués (@listPerformedWays.Count())</h3>
    @foreach(var item in listPerformedWays)
    {
        <div class="item-way">
            <div class="field">
                <label>Evenement</label>
                <span>@item.Event.Title - @item.Event.DateBegin.ToStringFr() (@item.Event.City)</span>
            </div>
            <div class="field">
                <label>Vehicule</label>
                <span>@item.Vehicule.BrandAndModelToString</span>
            </div>
            <div class="field">
                <label>Rendez-vous</label>
                <span>@item.MeetingPlace - @item.MeetingHour</span>
            </div>
            <div class="field">
                <label>Participation</label>
                <span>@item.Contribution</span>
            </div>
            <div class="field">
                <label>Places disponibles</label>
                <span>@item.NumberPlaces</span>
            </div>
        </div>
    }
</div>

